<?php
/*
 *评价定时每天执行任务
 */
defined('In33hao') or exit('Access Invalid!');

class evaluateControl extends BaseCronControl
{


    public function indexOp()
    {
        $this->realOrder();
        $this->vrOrder();
    }

    public function realOrder()
    {
        $model = Model();
        $condition['evaluation_state'] = 0;
        $condition['order_state'] = ORDER_STATE_SUCCESS;
        $field = 'order_id,buyer_id,buyer_name';
        $res = $model->table('orders')->field($field)->where($condition)->select();
        if (!empty($res)) {
            foreach ($res as $v) {
                $order_id = $v['order_id'];
                $return = Logic('member_evaluate')->validation($order_id, $v['buyer_id']);
                if (!$return['state']) {
                    continue;
                }
                extract($return['data']);
                $return = Logic('member_evaluate')->save($_POST, $order_info, $store_info, $order_goods, $v['buyer_id'], $v['buyer_name']);
                if (!$return['state']) {
                    continue;
                }
                //评价结算佣金
                brokerageBill($order_info,5);
            }
        }

    }

    public function vrOrder()
    {
        $model = Model();
        $condition['order_state'] = ORDER_STATE_SUCCESS;
        $condition['use_state'] = 1;
        $condition['evaluation_state'] = 0;
        $field = 'order_id,buyer_id,buyer_name';
        $res = $model->table('vr_order')->field($field)->where($condition)->select();
        if (!empty($res)) {
            foreach ($res as $v) {
                $order_id = $v['order_id'];
                $return = Logic('member_evaluate')->validationVr($order_id, $v['buyer_id']);
                if (!$return['state']) {
                    continue;
                }
                extract($return['data']);
                $return = Logic('member_evaluate')->saveVr($_POST, $order_info, $store_info, $v['buyer_id'], $v['buyer_name']);
                if (!$return['state']) {
                    continue;
                }
                //评价结算佣金
                brokerageBill($order_info,5);
            }
        }
    }
}
